(function(){"use strict";BX.namespace("BX.Grid");BX.Grid.Resize=function(t){this.parent=null;this.lastRegisterButtons=null;this.init(t)};BX.Grid.Resize.prototype={init:function(t){this.parent=t;BX.addCustomEvent(window,"Grid::updated",BX.proxy(this.registerTableButtons,this));BX.addCustomEvent(window,"Grid::headerUpdated",BX.proxy(this.registerPinnedTableButtons,this));this.registerTableButtons();this.registerPinnedTableButtons()},destroy:function(){BX.removeCustomEvent(window,"Grid::updated",BX.proxy(this.registerTableButtons,this));BX.removeCustomEvent(window,"Grid::headerUpdated",BX.proxy(this.registerPinnedTableButtons,this));BX.type.isArray(this.lastRegisterButtons)&&this.lastRegisterButtons.forEach(jsDD.unregisterObject);(this.getButtons()||[]).forEach(jsDD.unregisterObject)},registerTableButtons:function(){(this.getButtons()||[]).forEach(this.register,this);this.registerPinnedTableButtons()},register:function(t){if(BX.type.isDomNode(t)){t.onbxdragstart=BX.delegate(this._onDragStart,this);t.onbxdragstop=BX.delegate(this._onDragEnd,this);t.onbxdrag=BX.delegate(this._onDrag,this);jsDD.registerObject(t)}},registerPinnedTableButtons:function(){if(this.parent.getParam("ALLOW_PIN_HEADER")){var t=this.getPinnedTableButtons();if(BX.type.isArray(this.lastRegisterButtons)&&this.lastRegisterButtons.length){this.lastRegisterButtons.forEach(jsDD.unregisterObject)}this.lastRegisterButtons=t;(this.getPinnedTableButtons()||[]).forEach(this.register,this)}},getButtons:function(){return BX.Grid.Utils.getByClass(this.parent.getRows().getHeadFirstChild().getNode(),this.parent.settings.get("classResizeButton"))},getPinnedTableButtons:function(){return BX.Grid.Utils.getByClass(this.parent.getPinHeader().getFixedTable(),this.parent.settings.get("classResizeButton"))},_onDragStart:function(){var t=BX.findParent(jsDD.current_node,{className:this.parent.settings.get("classHeadCell")});var e=this.parent.getRows().getHeadFirstChild().getCells();var i=Object.keys(e);var s;this.__overlay=BX.create("div",{props:{className:"main-grid-cell-overlay"}});BX.append(this.__overlay,t);this.__resizeCell=t.cellIndex;i.forEach(function(t){if(!BX.hasClass(e[t],"main-grid-special-empty")){var i=BX.width(e[t]);if(t>0){i-=parseInt(BX.style(e[t],"border-left-width"));i-=parseInt(BX.style(e[t],"border-right-width"))}BX.width(e[t],i);s=BX.firstChild(e[t]);BX.width(s,i)}})},_onDrag:function(t){var e=this.parent.getTable();var i=this.parent.getParam("ALLOW_PIN_HEADER")?this.parent.getPinHeader().getFixedTable():null;var s=e.rows[0].cells[this.__resizeCell];var n,r;var a=BX.pos(s);var o=parseFloat(s.style.width);var l;t-=a.left;l=t;if(a.width>o){t=a.width}t=l>t?l:t;t=Math.max(t,80);if(t!==a.width){var d=this.parent.getAllRows()[0].querySelectorAll(".main-grid-fixed-column").length;var h=this.parent.getColumnByIndex(this.__resizeCell-d);h.forEach(function(e){e.style.width=t+"px";e.style.minWidth=t+"px";e.style.maxWidth=t+"px"});if(h[0].classList.contains("main-grid-fixed-column")){h=this.parent.getColumnByIndex(this.__resizeCell-d+1);h.forEach(function(e){e.style.width=t+"px";e.style.minWidth=t+"px";e.style.maxWidth=t+"px"})}this.parent.adjustFixedColumnsPosition();this.parent.adjustFadePosition(this.parent.getFadeOffset());if(BX.type.isDomNode(i)&&BX.type.isDomNode(i.rows[0])){n=i.rows[0].cells[this.__resizeCell];r=BX.firstChild(n);r.style.width=t+"px";r.style.minWidth=t+"px";n.style.width=t+"px";n.style.minWidth=t+"px"}}BX.onCustomEvent(window,"Grid::columnResize",[])},_onDragEnd:function(){this.saveSizes()},getColumnSizes:function(){var t=this.parent.getRows().getHeadFirstChild().getCells();var e={};var i;[].forEach.call(t,function(t){i=BX.data(t,"name");if(BX.type.isNotEmptyString(i)){e[i]=BX.width(t)}},this);return e},saveSizes:function(){this.parent.getUserOptions().setColumnSizes(this.getColumnSizes(),1)}}})();
//# sourceMappingURL=resize.map.js